// -----------------------------------------------------------------------------
// all group 
// _playtype 参考 RateConfig_5h $this->playGroupArr 对应
// ----------------------------------------------------------------------------- 
var M = new Object();
M.Rates = new Array();
M.RatesTimeId = 0;
M.rateI = 0; 
$.fn.getAjaxRatedata = function(_lotto_id, _gametype, _playtype){
 if (M.RatesTimeId) { clearTimeout(M.RatesTimeId); }
 $().disAreaObj();
   var tempStr = '';
   // window.open('op.php?op=xml_3d&fp=rate_3ds&playtype=' + _playtype + '&lotto_id_3d=' + _lotto_id + "&gametype=" + _gametype + "&disk="+ $("select#slcDisk").val() + tempStr );
   $.getJSON('op.php?op=xml_3d&fp=rate_3ds&playtype=' + _playtype + '&lotto_id_3d=' + _lotto_id + "&gametype=" + _gametype + "&disk="+ $("select#slcDisk").val() + tempStr ,function(ratedata){
    var dataLen = 0;
    var urlPre = "";
    var hrefStr = "";

    if(ratedata == undefined){
      $("div#errormsg").addClass("error").text("系统维护中");
      return false;
    }else if(ratedata.errormsg != undefined){
      $("div#errormsg").addClass("error").text("No Rate data");
      return false;
    }else{
      var disk = $("select#slcDisk").val(); 
      var htmStr="";
      M.rateI = 0;
      switch(_playtype){
         case 'r1':
             htmStr = show_r1( ratedata,_lotto_id,_gametype,_playtype, disk );
             break;
         case 'r1p':
         case 'r2p':
         case 'r3p':
         case 'r4p':
         case 'r5p':
             htmStr = show_rxp(ratedata,_lotto_id,_gametype,_playtype, disk);
             break;
         default:
             htmStr = 'error show data'; $("#myDivTbl").html(htmStr); return false; break;
      }  
      $("#myDivTbl").html(htmStr);
    }
    
   $().redisAreaObj();   
   $("div#mainPageData").show();
   $("div#errormsg").text("");
   // change text or checkbox type
    var timebtnType = $("input:hidden#timebtnType").val();
    if(timebtnType == "checkbox"){
      $().timebtnTypeToCheckbox();
      $('#setMyNum2').css('display', '');
       $('#tblMy3DArea input:checkbox').click(function(){
          var chkVal = $(this).attr('checked');
          if(chkVal){ $(this).addTheValClr(null, '') }
          else{ $(this).clrTheValClr(null); }
        });
      
    }else{
      $('#tblMy3DArea input:text').change(function(){
        var chkVal = $(this).val();
        if(chkVal != ''){ $(this).addTheValClr(null, '') }
        else{ $(this).clrTheValClr(null); }
      });
    }
    
    $("#tblMy3DArea td:has(input)").parent("tr.td2").hover(
      function() {$(this).children().addClass("trover");}
      , function() {$(this).children().removeClass("trover");}
    );
    $('#myreset').click();
    // check rate each 30 sec
    //renewRateTimeObj = setTimeout(function(){$().renewR1data(_lotto_id,_gametype);}, renewRateTime);
    if( _timestap > 0 )
    {
      M.ReNewTime = Math.floor( ( Math.random() * 100 ) % 30 + 30 ) * 1000;
      M.RatesTimeId = setTimeout("$().getAjaxRatedata(" + _lotto_id + "," + _gametype + ",'" + _playtype + "');", M.ReNewTime);
    }else if ( M.RatesTimeId ) { clearTimeout(M.RatesTimeId); }
    
  });
};

// show table data
// jason data format={"bXX":{"number":["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21"],
//                          "rates":[1.92,1.92,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00]},

// bettype=12345
function show_r1(rdata,_lotto_id,_gametype,_playtype, disk){
  var sTblStr = '<br /><table class="tblMy3D" id="tblMy3DArea" style="table-layout:fixed; ">';
  var sStr = '';
  var showBetSubArr = '';
  var htmlTitle = '<td>号码</td><td>赔率</td><td>金额</td>';
  var i = 0;
  var l = 0;
  var oShow = '';
  var showTitleArr03 = [['大', '小'], ['单', '双']];
  var showTitleArr04 = [['总和大', '总和小'], ['总和单', '总和双']];
  var showTitleArr05 = [['龙', '虎','和']];
  var subidArr = '';
  var sTitle = '';
  var subidShow = '';
  var showBetSubArr = [
       ['第一球', [rdata.b2_1, rdata.b1_1], [2,1], [1, 1], showTitleArr03, 1, '']
      ,['第二球', [rdata.b2_2, rdata.b1_2], [2,1], [2, 2], showTitleArr03, 1, '']
      ,['第三球', [rdata.b2_3, rdata.b1_3], [2,1], [3, 3], showTitleArr03, 1, '']
      ,['第四球', [rdata.b2_4, rdata.b1_4], [2,1], [4, 4], showTitleArr03, 1, '']
      ,['第五球', [rdata.b2_5, rdata.b1_5], [2,1], [5, 5], showTitleArr03, 1, '']
      ,['', [rdata.b4_0, rdata.b3_0], [4,3], [0, 0], showTitleArr04, 1, '']
      ,['', [rdata.b5_0], [5], [0], showTitleArr05, 1, '']

  ];
  sStr += sTblStr;
  //sStr += '<tr  class="bgClc_' + _gametype + '" >' + htmlTitle+ htmlTitle+ htmlTitle+ htmlTitle + '</tr>';
  for(i = 0, l = showBetSubArr.length; i < l; i++){
    oShow =  showBetSubArr[i];
    if(i < 5)
    {
      sStr += '<tr  class="bgImg_' + _gametype + '" ><td colspan="12">' + oShow[0] + '</td></tr>';
      oShow[0] = '';
    }
    else if( i == 5)
    {
      sStr += '</table><br />' + sTblStr;
    }
    
    //if(i < 5) sStr += '<tr class="bgImg_' + _gametype   + '"><th colspan="12" height="25">' + oShow[0] + '</th></tr>';
    sStr += crt_2face_com(oShow[1], oShow[2], oShow[3], oShow[0], oShow[4], oShow[5], 4, disk, _playtype, oShow[6]);
  }
  
  sStr += '</table>';
  return sStr;
}

function show_rxp(rdata,_lotto_id,_gametype,_playtype, disk){
  var sStr = '';
  var sTblStr = '<table class="tblMy3D" width="700">';
  var sTblStr02 = '<table class="tblMy3D" width="700" style="table-layout:fixed;">';
  var showBetSubArr = '';
  var i = 0;
  var l = 0;
  var oShow = '';
  var showTitleArr = [['大', '小'], ['单', '双']];       
  var showTitleArr02 = [['总大', '总小'], ['总单', '总双']];
  var showTitleArr03 = [['龙', '虎', '和']];
  var showTitleArr04 = [['豹子', '顺子', '对子', '半顺', '杂六']];
  var subidArr = '';
  var sTitle = '';
  var subidShow = '';
  var rdataB0 = '';
  var rdataB1 = '';
  var rdataB2 = '';
  switch(_playtype){
    case 'r1p':
      sTitle = '第一球';
      subidShow = 1;
      rdataB0 = rdata.b0_1;
      rdataB1 = rdata.b1_1;
      rdataB2 = rdata.b2_1;
      break;
      
    case 'r2p':
      sTitle = '第二球';
      subidShow = 2;
      rdataB0 = rdata.b0_2;
      rdataB1 = rdata.b1_2;
      rdataB2 = rdata.b2_2;
      break;
      
    case 'r3p':
      sTitle = '第三球';
      subidShow = 3;
      rdataB0 = rdata.b0_3;
      rdataB1 = rdata.b1_3;
      rdataB2 = rdata.b2_3;
      break;
      
    case 'r4p':
      sTitle = '第四球';
      subidShow = 4;
      rdataB0 = rdata.b0_4;
      rdataB1 = rdata.b1_4;
      rdataB2 = rdata.b2_4;
      break;
      
    case 'r5p':
      sTitle = '第五球';
      subidShow = 5;
      rdataB0 = rdata.b0_5;
      rdataB1 = rdata.b1_5;
      rdataB2 = rdata.b2_5;
      break;
      
    default :  return '-rpn error-'; break; 
  }
  var showBetSubArr = [
      ['', [rdataB2, rdataB1], [2,1], [subidShow, subidShow], showTitleArr, 1, '']
     ,['', [rdata.b4_0, rdata.b3_0], [4,3],[0, 0], showTitleArr02, 1, '']
     ,['', [rdata.b5_0], [5], [0], showTitleArr03, 1 , '' ]
     ,['前三', [rdata.b6_2], [6], [2], showTitleArr04, 1 , '' ]
     ,['中三', [rdata.b6_1], [6], [1], showTitleArr04, 1 , '' ]
     ,['后三', [rdata.b6_0], [6], [0], showTitleArr04, 1 , '' ]
  ];
  sStr = sTblStr;
  sStr += crt_1To21(rdataB0, 0, subidShow, sTitle, 2, disk, _playtype);
  oShow =  showBetSubArr[0];
  sStr += crt_2face_com(oShow[1], oShow[2], oShow[3], oShow[0], oShow[4], oShow[5], 4, disk, _playtype, oShow[6]); 
  sStr += '</table><br />';
  
  sStr += sTblStr;
  oShow =  showBetSubArr[1];
  sStr += crt_2face_com(oShow[1], oShow[2], oShow[3], oShow[0], oShow[4], oShow[5], 4, disk, _playtype, oShow[6]);
  oShow =  showBetSubArr[2];
  sStr += crt_2face_com(oShow[1], oShow[2], oShow[3], oShow[0], oShow[4], oShow[5], 4, disk, _playtype, oShow[6]);
  sStr += '</table><br />';
  
  sStr += sTblStr;
  for(i = 3, l = showBetSubArr.length; i < l; i++){
    oShow =  showBetSubArr[i];
    sStr += '<tr class="bgImg_' + _gametype + '"><th colspan="15">' + oShow[0] + '</th></tr>';
    oShow[0] = '';
    sStr += crt_2face_com(oShow[1], oShow[2], oShow[3], oShow[0], oShow[4], oShow[5], 5, disk, _playtype, oShow[6]);
  }
  sStr += '</table>';
  return sStr;
}


function show_setMyNum2(_playtype){
  switch(_playtype){
    case 'r1p': 
    case 'r2p':
    case 'r3p':
    case 'r4p':
    case 'r5p':
      $('#setMyNum2').html(crt_quick02('a', [1,1,1,1,1]) + '<br />');
      break;
    default: return 0; break;
  }
  $('#setMyNum2 input:button').click(function(){
    // type
    var timeBtnType = $("input:hidden#timebtnType").val();
    var attVal1 = '';
    var attVal2 = '';
    switch(timeBtnType){
      case 'text': attVal1 = 'value'; attVal2 = '*'; break;
      case 'checkbox': attVal1 = 'checked'; attVal2 = 'true'; break;
      default: alert('error type'); return false;
    }
    var oObj = $("#myDivTbl input:[name^='b_']");
    oObj.clrTheValClr(attVal1);
    return false;       
  });
  return 1;
}

$.fn.addTheValClr = function(attVal1, attVal2){
  if(attVal1 == null){ $(this).css('background-color', '#ffff8c'); }
  else{ $(this).css('background-color', '#ffff8c').attr(attVal1, attVal2); }
};

$.fn.clrTheValClr = function(attVal1){
  if(attVal1 != null){ $(this).removeAttr(attVal1); }
  $(this).removeAttr('disabled').css('background-color', '');
  
}

function crt_2face_com(rdata, bettype, subBettype, sTitle, showTitleArr, rowSpanN, tdNum, disk,playgroup, bgClass){
  var setBtnId = "";
  var str = '';
  var strTitle = "";
  var sNum = "";
  var sRate = "";
  var num = 0;
  var setBtnId = "";
  var nextI = -1;        // 可秀玩法
  var i = 0;
  var l = 0;
  var l2 = 0;
  var littletotal = 0;
  var classCount = 0;
  var titleTemp = '';
  var colTemp = '';
  var tempCount = 0;
  var urlPre = '';
  var showClass = '';
  var showSize = 3;
  var rateClass = "";
  var inpVal = "";
  if( tdNum > 4 && sTitle !='' ){ showSize = 2; }
  str = '<tr class="td2">';
  for(i = 0, l = rdata.length; i < l; i++ ){
    l2 = showTitleArr[i].length;
    if(i == 0 && sTitle != '') { str += '<th class="bgImg_' + _gametype + '" height="30">' + sTitle + '</th>'; }
    for(var j = 0; j < l2; j++){  // 双面
      tempCount++;
      sNum = rdata[i].number[j];
      sRate = rdata[i].rates[j];
      setBtnId = setBtnId = 'b_' + subBettype[i] + '_' +  bettype[i] + '_' + sNum;
      urlPre = 'op.php?op=member_3ds&fp=bet_fast&gametype=' + _gametype + '&disk=' + disk + '&palygroup=' + playgroup + '&bettype=' + bettype[i] + '&subid=' + subBettype[i] + '&num=' + sNum + '&rate=' + sRate;
      if(bgClass != ''){ showClass = ' ' + bgClass + sNum; }else{ showClass = ''; }
      if( M.Rates[M.rateI] == undefined ) { rateClass = ''; }
      else if( M.Rates[M.rateI] != sRate ) { rateClass = ' class="rc"'; }
      else { rateClass = ''; }
      M.Rates[M.rateI] = sRate;
      M.rateI++;
      inpVal = $('input[name="' + setBtnId + '"]').val();
      if( inpVal == undefined ) { inpVal = ''; }
      str += '<th class="title02_3d' + showClass + '" nowrap>' + showTitleArr[i][j] + '</th>';
      str += '<th' + rateClass + '><a href="' + urlPre + '" class="betRateNum" target="leftFrame">' + sRate + '</a></th>';
      str += '<td><input type="text" size="' + showSize + '"  value="' + inpVal + '" name="' + setBtnId + '" /></td>';
    }
  }
  if(tempCount < tdNum){
   for(i = 0; i < (tdNum - tempCount); i++){
    str += '<td></td><td></td><td></td>';
   }
  }
  return str;

}

// n1~n5 - money
function crt_1To21(rdata, bettype, subid, sTitle, iNumTr, disk, playgroup){
  var str = "";
  var urlPre = "";
  var setBtnId = "";
  var htmlTemp = '<tr class="td2">';
  var htmlTitle = '<th>号码</th><th>赔率</th><th>金额</th>';
  var trArr = new Array();
  var idx = 0;
  var dataLen = rdata.number.length;
  var i = 0;                
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';} 
  var oNum = 0;
  var oRate = 0;              
  var showTitleN = Math.floor(dataLen / iNumTr);
  var numClass = '';
  var numClassN = 0; 
  var rateClass = "";
  var inpVal = "";
  if((dataLen % iNumTr) > 0){showTitleN += 1; }           
  str += '<caption class="bgClc_' + _gametype   + '">' + sTitle + '</caption>';
  str += '<thead><tr class="td15">';
  for(i = 0; i < showTitleN; i++){ str += htmlTitle; }
  str += '</tr></thead>';
  str += '<tbody align=center id="tbdData">';
  for(i = 0; i < dataLen; i++){
    idx = i % iNumTr;
    oNum = rdata.number[i];
    oRate = rdata.rates[i];
    urlPre = 'op.php?op=member_3ds&fp=bet_fast&gametype=' + _gametype + '&disk=' + disk + '&palygroup=' + playgroup + '&bettype=' + bettype + '&subid=' + subid + '&num=' + oNum + '&rate=' + oRate;
    setBtnId = 'b_' + subid + '_' +  bettype + '_' + oNum;
    if( M.Rates[M.rateI] == undefined ) { rateClass = ''; }
    else if( M.Rates[M.rateI] != oRate ) { rateClass = ' class="rc"';  }
    else { rateClass = ''; }
    M.Rates[M.rateI] = oRate;
    M.rateI++;
    inpVal = $('input[name="' + setBtnId + '"]').val();
    if( inpVal == undefined ) { inpVal = ''; }
    //numClassN = oNum % 4;
    //if(numClassN == 0 ){numClassN = 4; }
    if(oNum > 18 ){numClassN = 4; }else{numClassN = 2;}
    numClass = 'four5hB0' + numClassN;
    trArr[idx] += '<td class="title02_3d ' + numClass + '">' + oNum + '</td>';
    trArr[idx] += '<td' + rateClass + '><a href="' + urlPre + '" class="betRateNum" target="leftFrame">' + oRate + '</a></th>';
    trArr[idx] += '<td><input type="text" size="3"  value="' + inpVal + '" name="' + setBtnId + '" /></td>'; 
  }
  if(idx++ != iNumTr){
    for(i = idx; i < iNumTr; i++){
      trArr[i] += '<td></td><td></td><td></td>';
    }
  }
  str += htmlTemp + trArr.join('</tr><tr class=td2 height="20">') + '</tr>';
  str += '</tbody>';
  return str;
}

function crt_quick02(quick01Id, showArr){
  var str = '';
  var quickArr = ['&nbsp;' , '头', '尾', '中发白', '方位', '快速'];
  var quickArrL = quickArr.length;
  var quickValArr = [['单','双','大','小','合单','合双'] , [' 0 ',' 1 ',' 2 '], [' 0 ',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ',' 8 ',' 9 '], ['中','发','白'], ['东','南','西','北'],['全选']];
  var quickValIDArr = [['A1','A2','B1','B2','C1','C2'] , ['G0','G1','G2'], ['H0','H1','H2','H3','H4','H5','H6','H7','H8','H9'], ['I1','I2','I3'], ['J1','J2','J3','J4'],['K1']];
  var quickValArrL = 0;
  var chkStr = '';
  var quick01IdStr = 'quick02_' + quick01Id + '_';
  var i = 0;
  var j = 0;
  var oQ = 0;
  var oID = 0;
  var sClass = 'colorBtnGray';
  for(i = 0; i < quickArrL; i++){
    if(showArr[i] > 0){
      if(i == 3){ str += '<br />';}
      str += '&nbsp;&nbsp;<label id="'+ quick01IdStr + i + '">' + quickArr[i];
      oQ = quickValArr[i];
      oID = quickValIDArr[i];
      for(j = 0, quickValArrL = oQ.length; j < quickValArrL; j++ ){
        str += '<input type="button" value="' + oQ[j] + '" id="qckBtn_' + oID[j] + '" class="' + sClass + '" />';
      }
      str += '</label>';
    }
  }
  return str;
}

// -----------------------------------------------------------------------------
// function
// -----------------------------------------------------------------------------

// change money input to fast checkbox button 
$.fn.timebtnTypeToCheckbox = function(){
	mysetcookie("timebtnType","checkbox",1);
  $("input:hidden#timebtnType").val("checkbox");
  $("#myDivTbl input:text[name^='b_']").each(function(){
    $(this).closest('td').html("<label style='display: block;'><input type=\"checkbox\" value=\"1\" name=\""+$(this).attr("name")+"\" /></label>");
    return true;
  });
  $("input:button#betByCheckBox").hide();
  $("input:button#betByTextMoney").show();
  $("input:button#btnSetMyNum").attr("disabled","true");
};

// chang fast to money input
$.fn.timebtnTypeText = function(){
	mysetcookie("timebtnType","text",1);
  $("input:hidden#timebtnType").val("text");
  $("input:checkbox[name^='b_']").each(function(){
    $(this).closest('td').html("<input type=\"text\" value=\"\" name=\""+$(this).attr("name")+"\" size=\"3\" />");
    return true;
  });
  $("input:button#betByTextMoney").hide();
  $("input:button#betByCheckBox").show();
  $("input:button#btnSetMyNum").removeAttr("disabled");         
};

$.fn.showNowTime = function(){
  var thisObj = $(this);
  var str = "时间：<b>"+ _now.getDate() +"【"+( _now.getHours() )+":"+( _now.getMinutes())+":"+( _now.getSeconds())+"】</b>";
  if(_timestap >=0){
    timediff = _timestap;
    days = Math.floor(timediff / (86400));   // 60 * 60 * 24
  	timediff -= days * (86400);
  	hours = Math.floor(timediff / (3600));  // 60 * 60
  	timediff -= hours * (3600);	
  	mins = Math.floor(timediff / (60));
  	timediff -= mins * (60);	
  	secs = Math.floor(timediff);
    str += "，距离【第" + _round + "期】截止下注时间还有 ";
    if (days > 0 ) str += "<b>" + days + "</b> 天 ";
    if (hours > 0) str += "<b>" + hours + "</b> 小时 ";
    if (mins > 0) str += "<b>" + mins + "</b> 分钟 ";
    str += "<b>" + secs + "</b> 秒 ";
    _timestap-=1;
  }else{
    str += "<font color=red><b>【" + _gametypeStr + "】已经截止下注！</b></font>";
    if ( M.RatesTimeId ) { clearTimeout(M.RatesTimeId); }
    setTimeout('parent.mainFrame.location.reload()',1000);
    setTimeout('parent.leftFrame.location.reload()',1000);
  }
  $(this).html(str);
  _now.setTime(_now.getTime() + 1000);
  setTimeout(function(){$(thisObj).showNowTime();},1000);
};

// 显示讯息方块(取代alert 因alert会使目前时间与截止下注时间暂时停止计算)
$.fn.showMyMsgBox = function(msg){
  $("div#show3dmsg").html("<span class=\"error3d\">"+msg+"</span><br /><input type=\"button\" align=\"center\" id=\"btnOkMsg\" class=\"btnchoice\" value=\"确定\" onclick=\"javascript:$().closeMyMsgBox();\" />");
  $("div#show3dmsg").addClass("show3dmsg").show();
};

$.fn.closeMyMsgBox = function(){
 $("div#show3dmsg").removeClass("show3dmsg").hide();
};

//  更新率赔率禁止使用
$.fn.disAreaObj = function(){
 $("select#slcDisk").attr("disabled","disabled");
 $("input:button#betByCheckBox").attr("disabled","disabled");
 $("input:button#betByTextMoney").attr("disabled","disabled");
 // $("input:button#betReNewRate").attr("disabled","disabled");
};

$.fn.redisAreaObj = function(){
 $("select#slcDisk").removeAttr("disabled");
 $("input:button#betByCheckBox").removeAttr("disabled");
 $("input:button#betByTextMoney").removeAttr("disabled");
 // $("input:button#betReNewRate").removeAttr("disabled");
};

function submitCom(){
    switch($("input:hidden#timebtnType").val()){
      case "text": //text
      if($("input:text[name^='b_'][value!='']").not("[value='*']").size() < 1){
        $().showMyMsgBox("请在文字方块中填入要下注的金额；<br />或使用“转送”钮将“*”字转为金额值");
        return false;
      }
      break;
      
      case "checkbox": // checkbox
      if($("input:checkbox[name^='b_']:checked").size() < 1){
        $().showMyMsgBox("请勾选要下注的内容");
        return false;
      }else if($("input:text#setMomney").val()< 1){
        $().showMyMsgBox("请于“金额”右侧之文字方块中输入下注金额");
        $("input:text#setMomney").focus();
        return false;
      }else if($("input:text#setMomney").val()< _betmin){
        $().showMyMsgBox("下注金额不能小于最低下注额("+_betmin+"元)");
        $("input:text#setMomney").focus();
        return false;
      }else {
        $("input:checkbox[name^='b_']:checked").val($("input:text#setMomney").val())
      } 
      break;
    }
  
  $("form input:submit").add("form input:button").attr("disabled","disabled");
  $("input#disk").attr("value",$("select#slcDisk option:selected").val());
  return true;
}

// -----------------------------------------------------------------------------
$(function(){

  // default value for checkbox or money input
  $("input#disk").attr("value",$("select#slcDisk option:selected").val());

  if($("input:hidden#timebtnType").val() == "text"){$("input:button#betByTextMoney").hide();}else{$("input:button#betByCheckBox").hide();}
                    
  // time of now
  $("span#showNowTime").showNowTime();
  
  $("div#mainPageData").hide();
  
  // get rate data and show table
  $().getAjaxRatedata(_lotto_id,_gametype,_playtype);
  
  // change to money input
  $("input:button#betByCheckBox").bind('click',function(){
    $().timebtnTypeToCheckbox();
  });
  // change to fast checkbox 
  $("input:button#betByTextMoney").bind('click',function(){$().timebtnTypeText();});
  
  // “transfer”
  $("input:button#btnSetMyNum").bind('click', function(){
    var setMomney = $("#setMomney").val(); 
    if(setMomney< 1){
      $().showMyMsgBox("请于“金额”右侧之文字方块中输入要转送之金额");
      $("input:text#setMomney").focus();
      return false;
    }else if(setMomney< _betmin){
      $().showMyMsgBox("下注金额不能小于最低下注额("+_betmin+"元)");
      $("input:text#setMomney").focus();
      return false;
    }else{
      $("input:text[name^='b'][value='*']").val(setMomney);
      $("input:text#setMomney").val("");
    } 
  });
  
  // before submit
  $("form").submit(function() {
    return submitCom();
  });
  
  $("input:button").hover(
      function() {this.style.color='#0000FF';}
      , function() {this.style.color='';}
  );

  
  // change rate by a,b,c,d disk
  $("select#slcDisk").change(function(){
    if (M.RatesTimeId) { clearTimeout(M.RatesTimeId); }
    $("input#disk").attr("value",$("select#slcDisk option:selected").val());
    M.Rates = new Array();
    $().getAjaxRatedata(_lotto_id,_gametype,_playtype);
  });
  
  // reset button
  $("input#myreset").click(function(){
    var timebtnType = $("input:hidden#timebtnType").val();
    var attVal1 = '';
    switch(timebtnType){
      case 'text': attVal1 = 'value'; break;
      case 'checkbox': attVal1 = 'checked'; break;
      default: alert('error type'); return false;
    }
    var oObj = $("#myDivTbl input:[name^='b_']");   
    oObj.clrTheValClr(attVal1);
    if($("#tblMy3DAreaS").length > 0){ $("#tblMy3DAreaS input:[name^='b_']").clrTheValClr('checked'); }
    $('input.quick5hType:checked').click();
  });
  
  // renew rate
//   $("#betReNewRate").click(function(){
//     if (M.RatesTimeId) { clearTimeout(M.RatesTimeId); }
//     if( _timestap > 0 )
//     {
//       $().getAjaxRatedata(_lotto_id,_gametype,_playtype);
//     }
//     else
//     {
//      $().showMyMsgBox('已截止下注!无法更新赔率!');
//     }
//   });
//   
  
  // show fast bet button
  show_setMyNum2(_playtype);
  
  // show number tbl
  if(chgBallArr.length > 0){
  $('.disClc').click(function(){
    $('.onClc').removeClass('onClc');
    $(this).addClass("onClc");  
    var myIDX = $(this).attr("id").substr(5);
    $('#chgBallAreaStr').empty().append(chgBallArr[myIDX]);
    $('#chgBallAreaStr td:even').css("background-color", "#e7ebef");
  });
  $('.disClc:eq(0)').click();
  if(_maxTotal > 0){
    $('#maxDisBall td').each(function(idx, ele){
      if($(ele).text() == _maxTotal){
        $(ele).css({'color':'#FA0300','font-weight':'900'});
      }                                
    });
  }
  if(_maxTotal0 > 0){
    $('#maxDisBall0 td').each(function(idx, ele){
      if($(ele).text() == _maxTotal0){
        $(ele).css({'color':'#FA0300','font-weight':'900'});
      }                                
    });
  }
}

}); 